/*
 * Copyright 2009 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.splink.deepsplink.page.state {
	/**
	 * Defines the current state of a page. Valid states are defined
	 * as public constants.
	 * 
	 * @author Max Kugland
	 */
	final public class PageState {
		/**
		 * The page is instantiated and has not been initialized yet
		 */
		public static const INSTANTIATED_STATE : PageState = new PageState(0, "Instantiated");
		/**
		 * The page is currently initializing. 
		 */
		public static const INITIALIZING_STATE : PageState = new PageState(1, "Initializing");
		/**
		 * The page is initialized and waiting for a show call
		 */
		public static const INITIALIZED_STATE : PageState = new PageState(2, "Initialized");
		/**
		 * The page's show transition is currently executing. 
		 */
		public static const SHOWING_STATE : PageState = new PageState(3, "Showing");
		/**
		 * The page is shown. 
		 */
		public static const SHOWN_STATE : PageState = new PageState(4, "Shown");
		/**
		 * The page's hide transition is currently executing. 
		 */
		public static const HIDING_STATE : PageState = new PageState(5, "Hiding");
		/**
		 * The page is hidden. 
		 */
		public static const HIDDEN_STATE : PageState = new PageState(6, "Hidden");
		/**
		 * The page is finalized. 
		 */
		public static const FINALIZED_STATE : PageState = new PageState(7, "Finalized");
		private var _type : uint;
		private var _name : String;

		public function PageState(type : uint, name : String) {
			_type = type;
			_name = name;
		}

		/**
		 * @return the type of the current state.
		 */
		public function get type() : uint {
			return _type;
		}

		public function toString() : String {
			return "PageState: " + _name + " (" + type + ")";
		}
	}
}
